-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(completions): improve cursor position detection #444
Conversation
way too slow |
lib/next_ls/helpers/ast_helpers.ex
Outdated
{tree, id} = | ||
ast | ||
|> Zipper.zip() | ||
|> Zipper.traverse(0, fn tree, id -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably want to keep an accumulator of the zipper when its at the spot it inserts the id, then instead of the second pass, we'll already be at the spot on the zipper to inject the cursor
error raised in Sourceror.Range.get_end_pos_for_interpolation_segments code located in my notes as it contains work code |
variables: Enum.uniq(env.variables) | ||
} | ||
%{ | ||
variables: Enum.uniq(env.variables) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably all the zipper stuff is slow but you could use MapSet here.
lib/next_ls/helpers/ast_helpers.ex
Outdated
Zipper.insert_right(cursor_tree, {:__cursor__, [], []}) | ||
end | ||
|
||
Zipper.top(cond_result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can return cond_result as well, wouldn't that be the zipper being at the cursor which you find in the with
clause in the build step.
Turns out most of the slowness comes from fetching the docs for every function and module. Will omit those and fetch on the completionItem/resolve request |
12d1d08
to
fcfc15f
Compare
- this makes completion faster because we defer fetching docs - we binary_to_term/encode the relevant data to put in the data which then gets sent back up on the resolve request - also includes signature in docs - makes cursor finding faster by skipping subtrees that don't contain the cursor position code is still WIP, which is why its ugly on average of typing around in the next_ls.ex file, completions seem to be around 45-55ms. still not as fast as I'd like them, but still decent-ish
d317cc9
to
23aebd7
Compare
Added a spitfire equivalent of the Code.Fragment.container_cursor_to_quoted function and that gives us the cursor position.
That will need some improvements, but is currently blocked on improving the lexer.